#include "Raise.h"
#include "IVisitor.h"

Raise::Raise(const exprTypePtr& type, const exprTypePtr& inst, const exprTypePtr& tback, const exprTypePtr& cause, int nodeId):
    stmtType(nodeId),
    _type(type),
    _inst(inst),
    _tback(tback),
    _cause(cause)
{
}
    
Raise::~Raise()
{
    
}
    
Ast::AstTypes Raise::type() const
{
    return Ast::Raise;
}
    

exprTypePtr Raise::type_()
{
    return _type;
}

void Raise::setType_(const exprTypePtr& type)
{
    _type = type;
}

exprTypePtr Raise::inst()
{
    return _inst;
}

void Raise::setInst(const exprTypePtr& inst)
{
    _inst = inst;
}

exprTypePtr Raise::tback()
{
    return _tback;
}

void Raise::setTback(const exprTypePtr& tback)
{
    _tback = tback;
}

exprTypePtr Raise::cause()
{
    return _cause;
}

void Raise::setCause(const exprTypePtr& cause)
{
    _cause = cause;
}

    
QString Raise::toString() const
{
    return QString("Raise[type=%1, inst=%2, tback=%3, cause=%4]").
                arg(_type ? _type->toString():"").
                arg(_inst ? _inst->toString():"").
                arg(_tback ? _tback->toString():"").
                arg(_cause ? _cause->toString():"");
}
    
void Raise::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitRaise(node.dynamicCast<Raise>());
}
    
void Raise::traverse(IVisitor* visitor)
{
    if (_type != NULL)
        _type->accept(visitor, _type);
    if (_inst != NULL)
        _inst->accept(visitor, _inst);
    if (_tback != NULL)
        _tback->accept(visitor, _tback);
    if (_cause != NULL)
        _cause->accept(visitor, _cause);
}